﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Prism.Mvvm;
using System.Windows;
using HandyControl.Controls;

using MessageBox = HandyControl.Controls.MessageBox;
using Prism.Services.Dialogs;

namespace YJTMedicalAideManage.Cores
{
    public class InheritBase : BindableBase
    {
        /// <summary>
        /// 信息提示
        /// </summary>
        /// <param name="msg"></param>
        public void MessgaeSuccess(string msg)
        {

            MessageBox.Success(msg, "提示");
        }
        /// <summary>
        /// 信息提示
        /// </summary>
        /// <param name="msg"></param>
        public MessageBoxResult MessgaeInfo(string msg)
        {

           return MessageBox.Show(msg, "提示", MessageBoxButton.YesNo, MessageBoxImage.Information);
        }
        /// <summary>
        /// 警告提示
        /// </summary>
        /// <param name="msg"></param>
        public void MessgaeWarning(string msg)
        {
            MessageBox.Show(msg, "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning);
        }
        /// <summary>
        /// 错误提示
        /// </summary>
        /// <param name="msg"></param>
        public void MessgaeError(string msg)
        {
            MessageBox.Show(msg, "提示", MessageBoxButton.YesNo, MessageBoxImage.Error);
        }
        /// <summary>
        /// 将输入的字符转为大写
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public string ConvertToUpperIfEnglish(string input)
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                return input;
            }

            bool isEnglish = input.All(c => Char.IsLetter(c) && (Char.IsLower(c) || Char.IsUpper(c)));

            if (isEnglish)
            {
                return input.ToUpper();
            }

            return input;
        }
        public static List<string> CheckFields<T>(T obj)
        {
            List<string> emptyFields = new List<string>();

            var fields = typeof(T).GetFields(BindingFlags.Public | BindingFlags.Instance);

            foreach (var field in fields)
            {
                var value = field.GetValue(obj);

                if (value == null || (value is string str && string.IsNullOrEmpty(str)))
                {
                    emptyFields.Add(field.Name);
                }
            }

            return emptyFields;
        }
    }
}
